//
//  EvaluationViewController.m
//  Housekeeping
//
//  Created by 辰领科技 on 16/6/2.
//  Copyright © 2016年 yuf. All rights reserved.
//

#import "EvaluationViewController.h"
#import "UICustomActionSheet.h"
#import "UIImagePickerController+Edit.h"


#import "CommentsTableViewCell.h"

static NSString *CellIdentifier = @"CommentsTableViewCell";

@interface EvaluationViewController ()
<UITableViewDelegate,UITableViewDataSource,UIActionSheetDelegate,UITextViewDelegate>

@property (strong, nonatomic) IBOutlet UIView *navView;
@property (strong, nonatomic) IBOutlet UIScrollView *scroview;
@property (strong, nonatomic) IBOutlet UITableView *tableView;
@property (strong, nonatomic) IBOutlet UIView *changeImageView;
@property (strong, nonatomic) IBOutlet UIButton *maskButton;
@property (strong, nonatomic) IBOutlet UILabel *commentsLabel;
@property (strong, nonatomic) IBOutlet UIButton *button;


@property (strong, nonatomic) IBOutlet UIImageView *commodityImage;//商品图标
@property (strong, nonatomic) IBOutlet UILabel *commodityNameLabel;//商品名称
@property (strong, nonatomic) IBOutlet UILabel *commodityMoneyLabel;//价格 起售价
@property (strong, nonatomic) IBOutlet UILabel *timeLabel;//时间
@property (strong, nonatomic) IBOutlet UITextView *commentsTextView;//评论
@property (strong, nonatomic) IBOutlet UIButton *addPhotoButton;
@property (weak, nonatomic) IBOutlet UIImageView *addPhotoImage;
@property (nonatomic,strong) NSMutableArray * images;

@property (copy, nonatomic) NSString *imageStr;
@property (assign,nonatomic) BOOL  isFirst;

@property (weak, nonatomic) IBOutlet UIButton *moreButton;
@property (weak, nonatomic) IBOutlet UIButton *commentsNumber;
@property(nonatomic,strong)NSMutableArray * comentsArray;

@end

@implementation EvaluationViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    _comentsArray = [NSMutableArray array];
    _images = [NSMutableArray array];
    _isFirst = YES;
    _imageStr = @"";
    [self initViewLayout];
    [self requestData];
}


- (void)initViewLayout {
    [self adaptiveViewLayout:self.view];
    [self adaptiveViewLayout:self.navView];
    [self adaptiveViewLayout:self.scroview];
    [self adaptiveViewLayout:self.changeImageView];
    _scroview.contentSize = flexibleSize(CGSizeMake(0, 591), NO);
    
    
    _button.layer.cornerRadius = 21*VerticalRatio();
    
    [self.tableView registerNib:[UINib nibWithNibName:CellIdentifier bundle:nil] forCellReuseIdentifier:CellIdentifier];
    self.tableView.showsVerticalScrollIndicator = NO;

    
    self.commentsTextView.delegate = self;
      NSDictionary * dic =self.CommodityInformationDic[@"goodsList"][0];
    NSString * image = [NSString stringWithFormat:@"%@",dic[@"mgooImage"]];
    if (image.length>0) {
        [self.commodityImage sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",IP_Address_ImageDown_Fresh,image]]];
    }
    self.commodityNameLabel.text = [NSString stringWithFormat:@"%@",dic[@"mgooName"]];
    
    NSString *miflAmount = [NSString stringWithFormat:@"%@元起",self.CommodityInformationDic[@"mgooOrigPrice"]];
    NSString *integralRecordStr = [NSString stringWithFormat:@"价格:￥%@/m²  %@",dic[@"mgooPrice"]
                                   ,miflAmount];
    NSMutableAttributedString *noteStr = [[NSMutableAttributedString alloc] initWithString:integralRecordStr];
    [noteStr addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithWhite:0.525 alpha:1.000] range:NSMakeRange(noteStr.length-miflAmount.length, miflAmount.length)];
    [noteStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:10] range:NSMakeRange(noteStr.length-miflAmount.length, miflAmount.length)];
    
    [self.commodityMoneyLabel setAttributedText:noteStr];
    
    
    self.timeLabel.text = [NSString stringWithFormat:@"%@",self.CommodityInformationDic[@"createTime"]];
    
    _moreButton.layer.cornerRadius = 16.5*VerticalRatio();
    UIImage * Image = [UIImage imageNamed:@"houseClean9"];
    CGSize  size = [_moreButton.titleLabel.text sizeWithFont:_moreButton.titleLabel.font];
    [_moreButton setTitleEdgeInsets:UIEdgeInsetsMake(0, -Image.size.width*VerticalRatio(), 0, Image.size.width*VerticalRatio())];
    [_moreButton setImageEdgeInsets:UIEdgeInsetsMake(0, size.width, 0, - size.width)];

    
}


#pragma mark - <UITableViewDelegate && UITableViewDataSource>
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}
//定义 UITableView cell 的个数
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    NSInteger rows = _comentsArray.count;
    if (rows>2) {
        rows = 2;
    }
    return rows;
}

//定义 UITableView cell 的高度
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 72*VerticalRatio();
}

//定义 UITableView cell 展示的内容
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    CommentsTableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell= [[CommentsTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
        
    }
    for (UIView *view in cell.subviews) {
        if ([view isKindOfClass:[UILabel class]] ||[view isKindOfClass:[UIImageView class]]||[view isKindOfClass:[UIScrollView class]]||[view isKindOfClass:[UIButton class]]) {
            [view removeFromSuperview];
        }
    }
    NSDictionary * dic = _comentsArray[indexPath.row];
    NSString * image= [NSString stringWithFormat:@"%@",dic[@"mgooImg"]];
    if (image.length>0) {
        [cell.commentImage sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",IP_Address_ImageDown_Fresh,image]]];
    }
    
    cell.commentTitle.text = [NSString stringWithFormat:@"%@",dic[@"mgooName"]];
    cell.commentDetail.text = [NSString stringWithFormat:@"%@",dic[@"mgcoContent"]];
    NSString * date = [NSString stringWithFormat:@"%@",dic[@"mgcoDate"]];
    if (date.length>=19) {
        cell.commentDate.text = [date substringToIndex:19];
    }
    
    return cell;

    
    
    return cell;
}

#pragma mark - <UITextViewDelegate>
- (void)textViewDidChange:(UITextView *)textView{
    
    if (self.commentsTextView.text.length > 0) {
        self.commentsLabel.hidden = YES;
    }else{
        self.commentsLabel.hidden = NO;
    }
    
}

#pragma mark - 返回
- (IBAction)back:(id)sender {
    [self backBtn];
}

#pragma mark - 选择照片
- (IBAction)PublishImage:(id)sender {
    
    _changeImageView.hidden = NO;
    _maskButton.hidden = NO;
}
#pragma mark - 查看更多评论
- (IBAction)SeeMoreComments:(UIButton *)sender {
    UIStoryboard *secondStroyBoard = [UIStoryboard storyboardWithName:@"PersonalStoryboard" bundle:nil];
    UIViewController *page = [secondStroyBoard instantiateViewControllerWithIdentifier:@"Comments"];
    [[Common getNavigation]pushViewController:page];
    
}
#pragma mark - 取消选择照片
- (IBAction)cancelPublishImage:(id)sender {
    _changeImageView.hidden = YES;
    _maskButton.hidden = YES;
}
- (IBAction)ChooseWayButton:(UIButton *)sender {
    
    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) {
        UICustomActionSheet* actionSheet = [[UICustomActionSheet alloc] initWithTitle:@"" delegate:nil buttonTitles:@[@"",@""]];
        
        [actionSheet setButtonColors:@[[UIColor clearColor]]];
        [actionSheet setBackgroundColor:[UIColor clearColor]];
        
        [actionSheet setSubtitle:@""];
        [actionSheet setSubtitleColor:[UIColor clearColor]];
        
        [actionSheet showInView:self.view];
        
        UIImagePickerController *controller = [[UIImagePickerController alloc] init];
        __weak __typeof(self)weakSelf = self;
        [actionSheet hideAlert];
        if (sender.tag==100){
            controller.allowsEditing = YES;
            controller.sourceType = UIImagePickerControllerSourceTypeCamera;

            
            controller.finalizationBlock = ^(UIImagePickerController *picker, NSDictionary *info) {
                
                UIImage *image = info[UIImagePickerControllerEditedImage];
                
                _addPhotoButton.frame = flexibleFrame(CGRectMake(10+(_images.count+1)*70, 146, 65, 65), NO);
                _addPhotoImage.frame = flexibleFrame(CGRectMake(10+(_images.count+1)*70, 146, 65, 65), NO);
    
                UIButton * imageView = [[UIButton alloc]initWithFrame:flexibleFrame(CGRectMake(10+_images.count*70, 146, 65, 65), NO)];
                [imageView setBackgroundImage:image forState:UIControlStateNormal];
                [_scroview insertSubview:imageView aboveSubview:_addPhotoImage];
                
                
                
                [self imageUpload:1 :image];
                               // Dismiss when the crop mode was disabled
                if (picker.cropMode == DZNPhotoEditorViewControllerCropModeNone) {
                    [weakSelf dismissViewControllerAnimated:NO completion:^{
                    }];
                }
            };
            
            controller.cancellationBlock = ^(UIImagePickerController *picker) {
                
                // Dismiss when the crop mode was disabled or if the navigation stack has only one child view controller.
                if (picker.cropMode == DZNPhotoEditorViewControllerCropModeNone || picker.viewControllers.count == 1) {
                    [weakSelf dismissViewControllerAnimated:NO completion:^{
                    }];
                }
                else {
                    picker.cropMode = DZNPhotoEditorViewControllerCropModeCircular;
                    [picker popViewControllerAnimated:YES];
                }
            };
            [self presentViewController:controller animated:NO completion:^{}];
        }else if (sender.tag==101){
            controller.allowsEditing = YES;
            controller.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
            
            controller.finalizationBlock = ^(UIImagePickerController *picker, NSDictionary *info) {
                
                UIImage *image = info[UIImagePickerControllerEditedImage];
                
                UIImageView * imageView = [[UIImageView alloc]initWithFrame:flexibleFrame(CGRectMake(10+_images.count*70, 146, 65, 65), NO)];
                imageView.image = image;
                [_scroview addSubview: imageView];
                
                _addPhotoButton.frame = flexibleFrame(CGRectMake(10+(_images.count+1)*70, 146, 65, 65), NO);

                [self imageUpload:1 :image];
                // Dismiss when the crop mode was disabled
                if (picker.cropMode == DZNPhotoEditorViewControllerCropModeNone) {
                    [weakSelf dismissViewControllerAnimated:NO completion:^{
                    }];
                }
            };
            
            controller.cancellationBlock = ^(UIImagePickerController *picker) {
                
                // Dismiss when the crop mode was disabled or if the navigation stack has only one child view controller.
                if (picker.cropMode == DZNPhotoEditorViewControllerCropModeNone || picker.viewControllers.count == 1) {
                    [weakSelf dismissViewControllerAnimated:NO completion:^{
                    }];
                }
                else {
                    picker.cropMode = DZNPhotoEditorViewControllerCropModeCircular;
                    [picker popViewControllerAnimated:YES];
                }
            };
            [self presentViewController:controller animated:NO completion:^{}];
        }
        
        
        
        
    }else {
        UIActionSheet *ss=[[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"" destructiveButtonTitle:@"" otherButtonTitles:@"", nil];
        [ss showInView:self.view];
        UIImagePickerController *controller = [[UIImagePickerController alloc] init];
        __weak __typeof(self)weakSelf = self;
        [ss dismissWithClickedButtonIndex:0 animated:YES];
        if (sender.tag==100){
            controller.allowsEditing = YES;
            controller.sourceType = UIImagePickerControllerSourceTypeCamera;

            
            controller.finalizationBlock = ^(UIImagePickerController *picker, NSDictionary *info) {
                
                UIImage *image = info[UIImagePickerControllerEditedImage];
                
                UIImageView * imageView = [[UIImageView alloc]initWithFrame:flexibleFrame(CGRectMake(10+_images.count*70, 146, 65, 65), NO)];
                imageView.image = image;
                [_scroview addSubview: imageView];
                
                _addPhotoButton.frame = flexibleFrame(CGRectMake(10+(_images.count+1)*70, 146, 65, 65), NO);
    
                [self imageUpload:1 :image];
                // Dismiss when the crop mode was disabled
                if (picker.cropMode == DZNPhotoEditorViewControllerCropModeNone) {
                    [weakSelf dismissViewControllerAnimated:NO completion:^{
                    }];
                }
            };
            
            controller.cancellationBlock = ^(UIImagePickerController *picker) {
                
                // Dismiss when the crop mode was disabled or if the navigation stack has only one child view controller.
                if (picker.cropMode == DZNPhotoEditorViewControllerCropModeNone || picker.viewControllers.count == 1) {
                    [weakSelf dismissViewControllerAnimated:NO completion:^{
                    }];
                }
                else {
                    picker.cropMode = DZNPhotoEditorViewControllerCropModeCircular;
                    [picker popViewControllerAnimated:YES];
                }
            };
            [self presentViewController:controller animated:NO completion:^{}];
        }else if (sender.tag==101){
            controller.allowsEditing = YES;
            controller.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
            
            controller.finalizationBlock = ^(UIImagePickerController *picker, NSDictionary *info) {
                
                UIImage *image = info[UIImagePickerControllerEditedImage];
                
                UIImageView * imageView = [[UIImageView alloc]initWithFrame:flexibleFrame(CGRectMake(10+_images.count*70, 146, 65, 65), NO)];
                imageView.image = image;
                [_scroview addSubview: imageView];
                
                _addPhotoButton.frame = flexibleFrame(CGRectMake(10+(_images.count+1)*70, 146, 65, 65), NO);
                
                [self imageUpload:1 :image];
                
//                 Dismiss when the crop mode was disabled
                if (picker.cropMode == DZNPhotoEditorViewControllerCropModeNone) {
                    [weakSelf dismissViewControllerAnimated:NO completion:^{
                    }];
                }
            };
            
            controller.cancellationBlock = ^(UIImagePickerController *picker) {
                
                // Dismiss when the crop mode was disabled or if the navigation stack has only one child view controller.
                if (picker.cropMode == DZNPhotoEditorViewControllerCropModeNone || picker.viewControllers.count == 1) {
                    [weakSelf dismissViewControllerAnimated:NO completion:^{
                    }];
                }
                else {
                    picker.cropMode = DZNPhotoEditorViewControllerCropModeCircular;
                    [picker popViewControllerAnimated:YES];
                }
            };
            [self presentViewController:controller animated:NO completion:^{}];
        }
        
        
        
    }
    
    _changeImageView.hidden = YES;
    _maskButton.hidden = YES;

    
    _changeImageView.hidden = YES;
    _maskButton.hidden = YES;

}

#pragma mark - 上传图片--------------------------
- (void) imageUpload:(int)numberImg:(UIImage *)imageImage{
    NSString *url = [NSString stringWithFormat:@"%@%@",IP_Address_IMAGE,HK_uploadCommentImg];
    //分界线的标识符
    NSString *TWITTERFON_FORM_BOUNDARY = @"AaB03x";
    //根据url初始化request
    NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url]
                                                           cachePolicy:NSURLRequestReloadIgnoringLocalCacheData
                                                       timeoutInterval:10];
    //分界线 --AaB03x
    NSString *MPboundary=[[NSString alloc]initWithFormat:@"--%@",TWITTERFON_FORM_BOUNDARY];
    //结束符 AaB03x--
    NSString *endMPboundary=[[NSString alloc]initWithFormat:@"%@--",MPboundary];
    //要上传的图片
    //    UIImage *image=[params objectForKey:@"pic"];
    //得到图片的data
    CGSize newSize = CGSizeMake(80, 80);
    UIGraphicsBeginImageContext(newSize);
    [imageImage drawInRect:CGRectMake(0,0,newSize.width,newSize.height)];
    UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    NSData* data  = UIImageJPEGRepresentation(newImage, 0.7);
    //http body的字符串
    NSMutableString *body=[[NSMutableString alloc]init];
    //设置HTTPHeader中Content-Type的值
    NSString* content=[[NSString alloc]initWithFormat:@"multipart/form-data; boundary=%@",TWITTERFON_FORM_BOUNDARY];
    ////添加分界线，换行
    [body appendFormat:@"%@\r\n",MPboundary];
    //声明pic字段，文件名为boris.png
    [body appendFormat:@"Content-Disposition: form-data; name=\"pic\"; filename=\"boris.png\"\r\n"];
    //声明上传文件的格式
    [body appendFormat:@"Content-Type: image/png\r\n\r\n"];
    //    [body appendFormat:@"Content-Type: %@\r\n\r\n",content];
    //声明结束符：--AaB03x--
    NSString *end=[[NSString alloc]initWithFormat:@"\r\n%@",endMPboundary];
    //声明myRequestData，用来放入http body
    NSMutableData *myRequestData=[NSMutableData data];
    //将body字符串转化为UTF8格式的二进制
    [myRequestData appendData:[body dataUsingEncoding:NSUTF8StringEncoding]];
    //将image的data加入
    [myRequestData appendData:data];
    //加入结束符--AaB03x--
    [myRequestData appendData:[end dataUsingEncoding:NSUTF8StringEncoding]];
    NSString *headerUserAgent=@"";
    if ([Common getLoginStatus]) {
        NSString *userName = [[Common getLoginInfo] objectForKey:Key_User_nickname];
        NSString *userId  = [NSString stringWithFormat:@"%@",[[Common getLoginInfo] objectForKey:Key_User_userId]];
        NSString *encryptPwd  = [ [Common getLoginInfo] objectForKey:Key_User_password];
        NSString *localUserIdentify  = [[UIDevice currentDevice].identifierForVendor UUIDString];
        headerUserAgent = [NSString stringWithFormat:@"%@|%@|%@|%@",userName,userId,encryptPwd,localUserIdentify];
    }else{
        headerUserAgent = @"|||";
    }
    
    //设置HTTPHeader
    [request setValue:content forHTTPHeaderField:@"Content-Type"];
    //设置User-Agent
    [request setValue:headerUserAgent forHTTPHeaderField:@"User-Agent"];
    //设置Content-Length
    [request setValue:[NSString stringWithFormat:@"%d", [myRequestData length]] forHTTPHeaderField:@"Content-Length"];
    //设置http body
    [request setHTTPBody:myRequestData];
    //http method
    [request setHTTPMethod:@"POST"];
    
    //建立连接，设置代理
    //    NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:request delegate:self];
    //上传文件开始
    NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
    //获得返回值
    NSString *returnString = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding];
    
    NSData *jsonData = [returnString dataUsingEncoding:NSUTF8StringEncoding];
    NSError *error = nil;
    NSMutableDictionary *dictionary = [[CJSONDeserializer deserializer] deserializeAsDictionary:jsonData error:&error];
    
    //取得返回的图片名
    //    NSArray* array = [returnString componentsSeparatedByString:@"###"];
    //    NSString * image = [NSString stringWithFormat:@"%@", dictionary[@"result"][0][@"simaId"]];
    NSString * image = dictionary[@"title"];
    [_images addObject:image];
//    if (image.length>0) {
//        _imageStr = image;
//        //        _headImageUrl = dictionary[@"result"][0][@"simaImagUri"];
//    }else{
//        _imageStr = @"";
//    }
}


#pragma mark - 提交评论
- (IBAction)SubmitComments:(id)sender {
    NSMutableDictionary * dic = [NSMutableDictionary dictionary];
    [dic setObject:[Common getLoginInfo][Key_User_userId] forKey:@"museId"];
    [dic setObject:[Common getLoginInfo][Key_User_password] forKey:@"musePwd"];
    [dic setObject:[Common getLoginInfo][Key_User_onlineKey] forKey:@"museOnlineTag"];
    [dic setObject:self.commentsTextView.text forKey:@"mgcoContent"];
    [dic setObject:self.mgcoOrderDetailId forKey:@"mgcoOrderDetailId"];
    
    for (int i = 0; i<_images.count; i++) {
        NSString * image = _images[i];
        if (i!=0) {
            image = [NSString stringWithFormat:@",%@",image];
        }
        _imageStr = [_imageStr stringByAppendingString:image];
    }
    
    [dic setObject:self.imageStr forKey:@"mgcoImage"];
    [dic setObject:@"10" forKey:@"mgcoCommentStars"];
    [dic setObject:@"10" forKey:@"mgcoServiceStars"];
    [dic setObject:@"1" forKey:@"mgcoIsAnonymous"];
    
    self.shareApi.delegate = self;
    [self.shareApi  requestOperationWithDic:dic withPath:HK_saveMallGoodsComment withHttpType:@"POST" withTag:HK_HK_saveMallGoodsComment];
}



#pragma   mark - 请求我的评论
- (void)requestData {
    NSMutableDictionary * dic = [NSMutableDictionary dictionary];
    [dic setObject:[Common getLoginInfo][Key_User_userId] forKey:@"museId"];
    [dic setObject:[Common getLoginInfo][Key_User_password] forKey:@"musePwd"];
    [dic setObject:[Common getLoginInfo][Key_User_onlineKey] forKey:@"museOnlineTag"];
//    [dic setObject:[NSNumber numberWithInt:_pageNO] forKey:@"page"];
    [dic setObject:[NSNumber numberWithInt:PageSize] forKey:@"pageSize"];
    self.shareApi.delegate = self;
    [self.shareApi  requestOperationWithDic:dic withPath:HK_queryMyMallGoodsComment withHttpType:@"POST" withTag:HK_HK_queryMyMallGoodsComment];
}

#pragma   mark---- GetADBanner Request Delegate

- (void)fetchDatabaseFinished:(NSMutableDictionary *)database withTag:(NSInteger)tag{
    if (tag == HK_HK_saveMallGoodsComment){
        if (  [[database valueForKey:@"flag"] integerValue]!=1 ) {
            
            [[CWHUDTips sharedInstance]  showTips:[database valueForKey:@"msg"]  withStatus:1 dismissAfter:1.5];
        }else  {
            
            [CWHUDTips showTips:@"提交成功"];
            [self backBtn];
        }
    }else if (tag == HK_HK_queryMyMallGoodsComment){
        if (  [[database valueForKey:@"flag"] integerValue]!=1 ) {
            
            [[CWHUDTips sharedInstance]  showTips:[database valueForKey:@"msg"]  withStatus:1 dismissAfter:1.5];
        }else  {
    
                NSArray *arr = database[@"result"][@"rows"];
                for (id entity in arr) {
                    [self.comentsArray addObject:entity];
                }
            NSInteger height = 0;
            if (_comentsArray.count==0) {
                _moreButton.hidden = YES;
            }else{
                NSInteger rows = _comentsArray.count;
                if (_comentsArray.count>2) {
                    rows = 2;
                }
                height = 73*rows;
            }
            
            _tableView.frame = flexibleFrame(CGRectMake(0, 326, 320, height), NO);
            _moreButton.frame = flexibleFrame(CGRectMake(11, CGRectGetMaxY(_tableView.frame)/VerticalRatio()+5, 297, 33), NO);
            _scroview.contentSize = flexibleSize(CGSizeMake(0, CGRectGetMaxY(_moreButton.frame)/VerticalRatio()+5), NO);
            
            [_commentsNumber setTitle:[NSString stringWithFormat:@"累计评价(%d)",_comentsArray.count] forState:UIControlStateNormal];
            _tableView.delegate = self;
            _tableView.dataSource = self;
            [_tableView reloadData];
        }
    }
}

- (void)fetchDatabaseFailed:(NSError *)error message:(NSString *)message{
    
    [self dismissWaitDialog];
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
